package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.StVerificationQrCode;
import com.ruoyi.system.service.IStVerificationQrCodeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 核销记录Controller
 * 
 * @author ruoyi
 * @date 2024-07-15
 */
@RestController
@RequestMapping("/system/code")
public class StVerificationQrCodeController extends BaseController
{
    @Autowired
    private IStVerificationQrCodeService stVerificationQrCodeService;

    /**
     * 查询核销记录列表
     */

    @GetMapping("/list")
    public TableDataInfo list(StVerificationQrCode stVerificationQrCode)
    {
        startPage();
        List<StVerificationQrCode> list = stVerificationQrCodeService.selectStVerificationQrCodeList(stVerificationQrCode);
        return getDataTable(list);
    }

    /**
     * 导出核销记录列表
     */

    @Log(title = "核销记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StVerificationQrCode stVerificationQrCode)
    {
        List<StVerificationQrCode> list = stVerificationQrCodeService.selectStVerificationQrCodeList(stVerificationQrCode);
        ExcelUtil<StVerificationQrCode> util = new ExcelUtil<StVerificationQrCode>(StVerificationQrCode.class);
        util.exportExcel(response, list, "核销记录数据");
    }

    /**
     * 获取核销记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:code:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(stVerificationQrCodeService.selectStVerificationQrCodeById(id));
    }

    /**
     * 新增核销记录
     */
    @PreAuthorize("@ss.hasPermi('system:code:add')")
    @Log(title = "核销记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StVerificationQrCode stVerificationQrCode)
    {
        return toAjax(stVerificationQrCodeService.insertStVerificationQrCode(stVerificationQrCode));
    }

    /**
     * 修改核销记录
     */
    @PreAuthorize("@ss.hasPermi('system:code:edit')")
    @Log(title = "核销记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StVerificationQrCode stVerificationQrCode)
    {
        return toAjax(stVerificationQrCodeService.updateStVerificationQrCode(stVerificationQrCode));
    }

    /**
     * 删除核销记录
     */
    @PreAuthorize("@ss.hasPermi('system:code:remove')")
    @Log(title = "核销记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(stVerificationQrCodeService.deleteStVerificationQrCodeByIds(ids));
    }
}
